-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: npm update --save #4223
Merged
Merged
fix: npm update --save #4223
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ruyadorno
added a commit
to ruyadorno/config
that referenced
this pull request
Jan 10, 2022
Add a new method `isDefault(key)` that enables a way to know if the value to be returned by a `config.get(key)` call is coming from the default definitions or any other different source. In case it's coming from the default values this method returns `true`, it returns `false` otherwise. This addition is going to allow for effectively managing different default values in the npm cli on a command-basis, e.g: The `save` config default value in the npm cli is `true`, so that in `npm install` and other commands that value is always going to default to true if no user config is provided. Now let's say we want to use a different value in `npm update`, for example `save=false`. This change enables us to have a conditional check to see if the `save` config value is coming from the default source, thus providing a way to use a different value instead of the default: const save = config.isDefault('save') ? false : config.get('save') Relates to: npm/cli#4223 Relates to: npm/statusboard#324
ruyadorno
added a commit
to npm/config
that referenced
this pull request
Jan 10, 2022
Add a new method `isDefault(key)` that enables a way to know if the value to be returned by a `config.get(key)` call is coming from the default definitions or any other different source. In case it's coming from the default values this method returns `true`, it returns `false` otherwise. This addition is going to allow for effectively managing different default values in the npm cli on a command-basis, e.g: The `save` config default value in the npm cli is `true`, so that in `npm install` and other commands that value is always going to default to true if no user config is provided. Now let's say we want to use a different value in `npm update`, for example `save=false`. This change enables us to have a conditional check to see if the `save` config value is coming from the default source, thus providing a way to use a different value instead of the default: const save = config.isDefault('save') ? false : config.get('save') Relates to: npm/cli#4223 Relates to: npm/statusboard#324
darcyclarke
added
semver:patch
semver patch level for changes
Release 8.x
work is associated with a specific npm 8 release
cmd:update
related to `npm update`
release: next
These items should be addressed in the next release
labels
Jan 11, 2022
Previously `npm update` was not respecting the `save` option, it would be impossible for users to use `npm update` and automatically update their `package.json` files. This fixes it by adding extra steps on `Arborist.reify._saveIdealTree` to read direct dependencies of any `package.json` and update them as needed when reifying using the `update` and `save` options. Fixes: npm#708 Fixes: npm#2704 Relates to: npm/feedback#270
ruyadorno
force-pushed
the
fix-npm-update-save
branch
from
January 12, 2022 03:39
f7456da
to
388ad0d
Compare
- Uses config.isDefault to set a different value for the `save` config for both the update and dedupe commands - Tweaks arborist to make sure saveIdealTree preserves the behavior of skipping writing to package-lock.json on save=false for install while still writing the lockfile for `npm update` with its new default value of save=false. - Updated and added some new tests on arborist to cover for these tweaks - Added `npm update --save` smoke test on cli
ruyadorno
force-pushed
the
fix-npm-update-save
branch
from
January 12, 2022 03:48
388ad0d
to
3bb7bac
Compare
ruyadorno
force-pushed
the
fix-npm-update-save
branch
from
January 20, 2022 03:27
b50701a
to
49d9a3d
Compare
- added more tests scenarios - fixed some typos
ruyadorno
force-pushed
the
fix-npm-update-save
branch
from
January 20, 2022 03:40
49d9a3d
to
c0ad0f2
Compare
darcyclarke
approved these changes
Jan 20, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✅ LGTM
lukekarrys
approved these changes
Jan 20, 2022
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
cmd:update
related to `npm update`
release: next
These items should be addressed in the next release
Release 8.x
work is associated with a specific npm 8 release
semver:patch
semver patch level for changes
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously
npm update
was not respecting thesave
option, itwould be impossible for users to use
npm update
and automaticallyupdate their
package.json
files.This fixes it by adding extra steps on
Arborist.reify._saveIdealTree
to read direct dependencies of any
package.json
and update them asneeded when reifying using the
update
andsave
options.Also the follow up changes make sure to integrate the original arborist fix
into the cli while better documenting these expectations:
config.isDefault
to set a different value for thesave
configfor both the
update
anddedupe
commandssaveIdealTree
preserves the behavior ofskipping writing to
package-lock.json
onsave=false
for install whilestill writing the lockfile for
npm update
with its new default valueof
save=false
.npm update --save
smoke test on cliReferences
Fixes: #708
Fixes: #2704
Relates to: npm/feedback#270